<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function setCookie(name, value, pre) {
            let str = name + "=" + value;
            if (typeof pre === "number") {
                let date = new Date();
                date.setDate(date.getDate() + pre);
                str += ";expires=" + date;
            }
            document.cookie = str;
        }

        // setCookie("adasd", "asdasd", 5)

        function getCookie(name) {
            let arr = document.cookie.split("; ");
            // console.log(arr)
            arr.forEach((item, index) => {
                item = item.split("=");
                if (item[0] === name) {
                    console.log(item[1])
                }
            })
        }
        getCookie("adasd")

        function removeCookie(name) {
            setCookie(name, "", -1)
        }
    </script>
</body>

</html>